// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the App Engine Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_appengine_v1::client::Applications;
/// let client = Applications::builder().build().await?;
/// // use `client` to make requests to the App Engine Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages App Engine applications.
///
/// # Configuration
///
/// To configure `Applications` use the `with_*` methods in the type returned
/// by [builder()][Applications::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://appengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::applications::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::applications::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Applications` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Applications` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Applications {
    inner: std::sync::Arc<dyn super::stub::dynamic::Applications>,
}

impl Applications {
    /// Returns a builder for [Applications].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_appengine_v1::client::Applications;
    /// let client = Applications::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::applications::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::applications::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Applications + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Applications>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Applications> {
        super::transport::Applications::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Applications> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Applications::new)
    }

    /// Gets information about an application.
    pub fn get_application(&self) -> super::builder::applications::GetApplication {
        super::builder::applications::GetApplication::new(self.inner.clone())
    }

    /// Creates an App Engine application for a Google Cloud Platform project.
    /// Required fields:
    ///
    /// * `id` - The ID of the target Cloud Platform project.
    /// * *location* - The [region](https://cloud.google.com/appengine/docs/locations) where you want the App Engine application located.
    ///
    /// For more information about App Engine applications, see [Managing Projects, Applications, and Billing](https://cloud.google.com/appengine/docs/standard/python/console/).
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_application(&self) -> super::builder::applications::CreateApplication {
        super::builder::applications::CreateApplication::new(self.inner.clone())
    }

    /// Updates the specified Application resource.
    /// You can update the following fields:
    ///
    /// * `auth_domain` - Google authentication domain for controlling user access to the application.
    /// * `default_cookie_expiration` - Cookie expiration policy for the application.
    /// * `iap` - Identity-Aware Proxy properties for the application.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_application(&self) -> super::builder::applications::UpdateApplication {
        super::builder::applications::UpdateApplication::new(self.inner.clone())
    }

    /// Recreates the required App Engine features for the specified App Engine
    /// application, for example a Cloud Storage bucket or App Engine service
    /// account.
    /// Use this method if you receive an error message about a missing feature,
    /// for example, *Error retrieving the App Engine service account*.
    /// If you have deleted your App Engine service account, this will
    /// not be able to recreate it. Instead, you should attempt to use the
    /// IAM undelete API if possible at <https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/undelete?apix_params=%7B>"name"%3A"projects%2F-%2FserviceAccounts%2Funique_id"%2C"resource"%3A%7B%7D%7D .
    /// If the deletion was recent, the numeric ID can be found in the Cloud
    /// Console Activity Log.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn repair_application(&self) -> super::builder::applications::RepairApplication {
        super::builder::applications::RepairApplication::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::applications::ListOperations {
        super::builder::applications::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::applications::GetOperation {
        super::builder::applications::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the App Engine Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_appengine_v1::client::Services;
/// let client = Services::builder().build().await?;
/// // use `client` to make requests to the App Engine Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages services of an application.
///
/// # Configuration
///
/// To configure `Services` use the `with_*` methods in the type returned
/// by [builder()][Services::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://appengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::services::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::services::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Services` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Services` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Services {
    inner: std::sync::Arc<dyn super::stub::dynamic::Services>,
}

impl Services {
    /// Returns a builder for [Services].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_appengine_v1::client::Services;
    /// let client = Services::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::services::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::services::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Services + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Services>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Services> {
        super::transport::Services::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Services> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Services::new)
    }

    /// Lists all the services in the application.
    pub fn list_services(&self) -> super::builder::services::ListServices {
        super::builder::services::ListServices::new(self.inner.clone())
    }

    /// Gets the current configuration of the specified service.
    pub fn get_service(&self) -> super::builder::services::GetService {
        super::builder::services::GetService::new(self.inner.clone())
    }

    /// Updates the configuration of the specified service.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_service(&self) -> super::builder::services::UpdateService {
        super::builder::services::UpdateService::new(self.inner.clone())
    }

    /// Deletes the specified service and all enclosed versions.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_service(&self) -> super::builder::services::DeleteService {
        super::builder::services::DeleteService::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::services::ListOperations {
        super::builder::services::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::services::GetOperation {
        super::builder::services::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the App Engine Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_appengine_v1::client::Versions;
/// let client = Versions::builder().build().await?;
/// // use `client` to make requests to the App Engine Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages versions of a service.
///
/// # Configuration
///
/// To configure `Versions` use the `with_*` methods in the type returned
/// by [builder()][Versions::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://appengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::versions::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::versions::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Versions` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Versions` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Versions {
    inner: std::sync::Arc<dyn super::stub::dynamic::Versions>,
}

impl Versions {
    /// Returns a builder for [Versions].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_appengine_v1::client::Versions;
    /// let client = Versions::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::versions::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::versions::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Versions + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Versions>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Versions> {
        super::transport::Versions::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Versions> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Versions::new)
    }

    /// Lists the versions of a service.
    pub fn list_versions(&self) -> super::builder::versions::ListVersions {
        super::builder::versions::ListVersions::new(self.inner.clone())
    }

    /// Gets the specified Version resource.
    /// By default, only a `BASIC_VIEW` will be returned.
    /// Specify the `FULL_VIEW` parameter to get the full resource.
    pub fn get_version(&self) -> super::builder::versions::GetVersion {
        super::builder::versions::GetVersion::new(self.inner.clone())
    }

    /// Deploys code and resource files to a new version.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_version(&self) -> super::builder::versions::CreateVersion {
        super::builder::versions::CreateVersion::new(self.inner.clone())
    }

    /// Updates the specified Version resource.
    /// You can specify the following fields depending on the App Engine
    /// environment and type of scaling that the version resource uses:
    ///
    /// **Standard environment**
    ///
    /// * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class)
    ///
    /// *automatic scaling* in the standard environment:
    ///
    /// * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
    /// * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
    /// * [`automaticScaling.standard_scheduler_settings.max_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)
    /// * [`automaticScaling.standard_scheduler_settings.min_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)
    /// * [`automaticScaling.standard_scheduler_settings.target_cpu_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)
    /// * [`automaticScaling.standard_scheduler_settings.target_throughput_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)
    ///
    /// *basic scaling* or *manual scaling* in the standard environment:
    ///
    /// * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status)
    /// * [`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling)
    ///
    /// **Flexible environment**
    ///
    /// * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status)
    ///
    /// *automatic scaling* in the flexible environment:
    ///
    /// * [`automatic_scaling.min_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
    /// * [`automatic_scaling.max_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
    /// * [`automatic_scaling.cool_down_period_sec`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
    /// * [`automatic_scaling.cpu_utilization.target_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
    ///
    /// *manual scaling* in the flexible environment:
    ///
    /// * [`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling)
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_version(&self) -> super::builder::versions::UpdateVersion {
        super::builder::versions::UpdateVersion::new(self.inner.clone())
    }

    /// Deletes an existing Version resource.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_version(&self) -> super::builder::versions::DeleteVersion {
        super::builder::versions::DeleteVersion::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::versions::ListOperations {
        super::builder::versions::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::versions::GetOperation {
        super::builder::versions::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the App Engine Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_appengine_v1::client::Instances;
/// let client = Instances::builder().build().await?;
/// // use `client` to make requests to the App Engine Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages instances of a version.
///
/// # Configuration
///
/// To configure `Instances` use the `with_*` methods in the type returned
/// by [builder()][Instances::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://appengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::instances::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::instances::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Instances` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Instances` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Instances {
    inner: std::sync::Arc<dyn super::stub::dynamic::Instances>,
}

impl Instances {
    /// Returns a builder for [Instances].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_appengine_v1::client::Instances;
    /// let client = Instances::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::instances::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::instances::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Instances + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Instances>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Instances> {
        super::transport::Instances::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Instances> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Instances::new)
    }

    /// Lists the instances of a version.
    ///
    /// Tip: To aggregate details about instances over time, see the
    /// [Stackdriver Monitoring API](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list).
    pub fn list_instances(&self) -> super::builder::instances::ListInstances {
        super::builder::instances::ListInstances::new(self.inner.clone())
    }

    /// Gets instance information.
    pub fn get_instance(&self) -> super::builder::instances::GetInstance {
        super::builder::instances::GetInstance::new(self.inner.clone())
    }

    /// Stops a running instance.
    ///
    /// The instance might be automatically recreated based on the scaling settings
    /// of the version. For more information, see "How Instances are Managed"
    /// ([standard environment](https://cloud.google.com/appengine/docs/standard/python/how-instances-are-managed) |
    /// [flexible environment](https://cloud.google.com/appengine/docs/flexible/python/how-instances-are-managed)).
    ///
    /// To ensure that instances are not re-created and avoid getting billed, you
    /// can stop all instances within the target version by changing the serving
    /// status of the version to `STOPPED` with the
    /// [`apps.services.versions.patch`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch)
    /// method.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_instance(&self) -> super::builder::instances::DeleteInstance {
        super::builder::instances::DeleteInstance::new(self.inner.clone())
    }

    /// Enables debugging on a VM instance. This allows you to use the SSH
    /// command to connect to the virtual machine where the instance lives.
    /// While in "debug mode", the instance continues to serve live traffic.
    /// You should delete the instance when you are done debugging and then
    /// allow the system to take over and determine if another instance
    /// should be started.
    ///
    /// Only applicable for instances in App Engine flexible environment.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn debug_instance(&self) -> super::builder::instances::DebugInstance {
        super::builder::instances::DebugInstance::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::instances::ListOperations {
        super::builder::instances::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::instances::GetOperation {
        super::builder::instances::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the App Engine Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_appengine_v1::client::Firewall;
/// let client = Firewall::builder().build().await?;
/// // use `client` to make requests to the App Engine Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Firewall resources are used to define a collection of access control rules
/// for an Application. Each rule is defined with a position which specifies
/// the rule's order in the sequence of rules, an IP range to be matched against
/// requests, and an action to take upon matching requests.
///
/// Every request is evaluated against the Firewall rules in priority order.
/// Processesing stops at the first rule which matches the request's IP address.
/// A final rule always specifies an action that applies to all remaining
/// IP addresses. The default final rule for a newly-created application will be
/// set to "allow" if not otherwise specified by the user.
///
/// # Configuration
///
/// To configure `Firewall` use the `with_*` methods in the type returned
/// by [builder()][Firewall::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://appengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::firewall::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::firewall::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Firewall` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Firewall` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Firewall {
    inner: std::sync::Arc<dyn super::stub::dynamic::Firewall>,
}

impl Firewall {
    /// Returns a builder for [Firewall].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_appengine_v1::client::Firewall;
    /// let client = Firewall::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::firewall::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::firewall::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Firewall + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Firewall>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Firewall> {
        super::transport::Firewall::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Firewall> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Firewall::new)
    }

    /// Lists the firewall rules of an application.
    pub fn list_ingress_rules(&self) -> super::builder::firewall::ListIngressRules {
        super::builder::firewall::ListIngressRules::new(self.inner.clone())
    }

    /// Replaces the entire firewall ruleset in one bulk operation. This overrides
    /// and replaces the rules of an existing firewall with the new rules.
    ///
    /// If the final rule does not match traffic with the '*' wildcard IP range,
    /// then an "allow all" rule is explicitly added to the end of the list.
    pub fn batch_update_ingress_rules(&self) -> super::builder::firewall::BatchUpdateIngressRules {
        super::builder::firewall::BatchUpdateIngressRules::new(self.inner.clone())
    }

    /// Creates a firewall rule for the application.
    pub fn create_ingress_rule(&self) -> super::builder::firewall::CreateIngressRule {
        super::builder::firewall::CreateIngressRule::new(self.inner.clone())
    }

    /// Gets the specified firewall rule.
    pub fn get_ingress_rule(&self) -> super::builder::firewall::GetIngressRule {
        super::builder::firewall::GetIngressRule::new(self.inner.clone())
    }

    /// Updates the specified firewall rule.
    pub fn update_ingress_rule(&self) -> super::builder::firewall::UpdateIngressRule {
        super::builder::firewall::UpdateIngressRule::new(self.inner.clone())
    }

    /// Deletes the specified firewall rule.
    pub fn delete_ingress_rule(&self) -> super::builder::firewall::DeleteIngressRule {
        super::builder::firewall::DeleteIngressRule::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::firewall::ListOperations {
        super::builder::firewall::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::firewall::GetOperation {
        super::builder::firewall::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the App Engine Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_appengine_v1::client::AuthorizedDomains;
/// let client = AuthorizedDomains::builder().build().await?;
/// // use `client` to make requests to the App Engine Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages domains a user is authorized to administer. To authorize use of a
/// domain, verify ownership via
/// [Webmaster Central](https://www.google.com/webmasters/verification/home).
///
/// # Configuration
///
/// To configure `AuthorizedDomains` use the `with_*` methods in the type returned
/// by [builder()][AuthorizedDomains::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://appengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::authorized_domains::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::authorized_domains::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `AuthorizedDomains` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `AuthorizedDomains` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct AuthorizedDomains {
    inner: std::sync::Arc<dyn super::stub::dynamic::AuthorizedDomains>,
}

impl AuthorizedDomains {
    /// Returns a builder for [AuthorizedDomains].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_appengine_v1::client::AuthorizedDomains;
    /// let client = AuthorizedDomains::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::authorized_domains::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::authorized_domains::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::AuthorizedDomains + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::AuthorizedDomains>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::AuthorizedDomains> {
        super::transport::AuthorizedDomains::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::AuthorizedDomains> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::AuthorizedDomains::new)
    }

    /// Lists all domains the user is authorized to administer.
    pub fn list_authorized_domains(
        &self,
    ) -> super::builder::authorized_domains::ListAuthorizedDomains {
        super::builder::authorized_domains::ListAuthorizedDomains::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::authorized_domains::ListOperations {
        super::builder::authorized_domains::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::authorized_domains::GetOperation {
        super::builder::authorized_domains::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the App Engine Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_appengine_v1::client::AuthorizedCertificates;
/// let client = AuthorizedCertificates::builder().build().await?;
/// // use `client` to make requests to the App Engine Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages SSL certificates a user is authorized to administer. A user can
/// administer any SSL certificates applicable to their authorized domains.
///
/// # Configuration
///
/// To configure `AuthorizedCertificates` use the `with_*` methods in the type returned
/// by [builder()][AuthorizedCertificates::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://appengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::authorized_certificates::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::authorized_certificates::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `AuthorizedCertificates` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `AuthorizedCertificates` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct AuthorizedCertificates {
    inner: std::sync::Arc<dyn super::stub::dynamic::AuthorizedCertificates>,
}

impl AuthorizedCertificates {
    /// Returns a builder for [AuthorizedCertificates].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_appengine_v1::client::AuthorizedCertificates;
    /// let client = AuthorizedCertificates::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::authorized_certificates::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::authorized_certificates::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::AuthorizedCertificates + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::AuthorizedCertificates>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::AuthorizedCertificates> {
        super::transport::AuthorizedCertificates::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::AuthorizedCertificates> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::AuthorizedCertificates::new)
    }

    /// Lists all SSL certificates the user is authorized to administer.
    pub fn list_authorized_certificates(
        &self,
    ) -> super::builder::authorized_certificates::ListAuthorizedCertificates {
        super::builder::authorized_certificates::ListAuthorizedCertificates::new(self.inner.clone())
    }

    /// Gets the specified SSL certificate.
    pub fn get_authorized_certificate(
        &self,
    ) -> super::builder::authorized_certificates::GetAuthorizedCertificate {
        super::builder::authorized_certificates::GetAuthorizedCertificate::new(self.inner.clone())
    }

    /// Uploads the specified SSL certificate.
    pub fn create_authorized_certificate(
        &self,
    ) -> super::builder::authorized_certificates::CreateAuthorizedCertificate {
        super::builder::authorized_certificates::CreateAuthorizedCertificate::new(
            self.inner.clone(),
        )
    }

    /// Updates the specified SSL certificate. To renew a certificate and maintain
    /// its existing domain mappings, update `certificate_data` with a new
    /// certificate. The new certificate must be applicable to the same domains as
    /// the original certificate. The certificate `display_name` may also be
    /// updated.
    pub fn update_authorized_certificate(
        &self,
    ) -> super::builder::authorized_certificates::UpdateAuthorizedCertificate {
        super::builder::authorized_certificates::UpdateAuthorizedCertificate::new(
            self.inner.clone(),
        )
    }

    /// Deletes the specified SSL certificate.
    pub fn delete_authorized_certificate(
        &self,
    ) -> super::builder::authorized_certificates::DeleteAuthorizedCertificate {
        super::builder::authorized_certificates::DeleteAuthorizedCertificate::new(
            self.inner.clone(),
        )
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::authorized_certificates::ListOperations {
        super::builder::authorized_certificates::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::authorized_certificates::GetOperation {
        super::builder::authorized_certificates::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the App Engine Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_appengine_v1::client::DomainMappings;
/// let client = DomainMappings::builder().build().await?;
/// // use `client` to make requests to the App Engine Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages domains serving an application.
///
/// # Configuration
///
/// To configure `DomainMappings` use the `with_*` methods in the type returned
/// by [builder()][DomainMappings::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://appengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::domain_mappings::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::domain_mappings::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `DomainMappings` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `DomainMappings` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct DomainMappings {
    inner: std::sync::Arc<dyn super::stub::dynamic::DomainMappings>,
}

impl DomainMappings {
    /// Returns a builder for [DomainMappings].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_appengine_v1::client::DomainMappings;
    /// let client = DomainMappings::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::domain_mappings::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::domain_mappings::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::DomainMappings + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::DomainMappings>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::DomainMappings> {
        super::transport::DomainMappings::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::DomainMappings> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::DomainMappings::new)
    }

    /// Lists the domain mappings on an application.
    pub fn list_domain_mappings(&self) -> super::builder::domain_mappings::ListDomainMappings {
        super::builder::domain_mappings::ListDomainMappings::new(self.inner.clone())
    }

    /// Gets the specified domain mapping.
    pub fn get_domain_mapping(&self) -> super::builder::domain_mappings::GetDomainMapping {
        super::builder::domain_mappings::GetDomainMapping::new(self.inner.clone())
    }

    /// Maps a domain to an application. A user must be authorized to administer a
    /// domain in order to map it to an application. For a list of available
    /// authorized domains, see [`AuthorizedDomains.ListAuthorizedDomains`]().
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_domain_mapping(&self) -> super::builder::domain_mappings::CreateDomainMapping {
        super::builder::domain_mappings::CreateDomainMapping::new(self.inner.clone())
    }

    /// Updates the specified domain mapping. To map an SSL certificate to a
    /// domain mapping, update `certificate_id` to point to an `AuthorizedCertificate`
    /// resource. A user must be authorized to administer the associated domain
    /// in order to update a `DomainMapping` resource.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_domain_mapping(&self) -> super::builder::domain_mappings::UpdateDomainMapping {
        super::builder::domain_mappings::UpdateDomainMapping::new(self.inner.clone())
    }

    /// Deletes the specified domain mapping. A user must be authorized to
    /// administer the associated domain in order to delete a `DomainMapping`
    /// resource.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_domain_mapping(&self) -> super::builder::domain_mappings::DeleteDomainMapping {
        super::builder::domain_mappings::DeleteDomainMapping::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::domain_mappings::ListOperations {
        super::builder::domain_mappings::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::domain_mappings::GetOperation {
        super::builder::domain_mappings::GetOperation::new(self.inner.clone())
    }
}
